package guoanmaker.operator.business.service;

import guoanmaker.operator.business.model.OperatorCouponPage;
import guoanmaker.operator.business.repository.OperatorCouponPageRepository;
import guoanmaker.operator.helper.common.AjaxJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *  
 *
 * @ClassName: OperatorCouponPageService 
 * @Description: OperatorCouponPageService 
 * @author: huZhaoyu 
 * @date 2017/6/28 下午2:56 
 */
@Service
public class OperatorCouponPageService implements OperatorCouponPageServiceInterface {
    private final OperatorCouponPageRepository operatorCouponPageRepository;

    @Autowired
    public OperatorCouponPageService(OperatorCouponPageRepository operatorCouponPageRepository) {
        this.operatorCouponPageRepository = operatorCouponPageRepository;
    }

    @Override
    public OperatorCouponPage saveCouponPage(OperatorCouponPage operatorCouponPage) {
        return operatorCouponPageRepository.save(operatorCouponPage);
    }

    @Override
    public List<OperatorCouponPage> getAllCouponPage() {
        return operatorCouponPageRepository.findAll();
    }

    @Override
    public Page<OperatorCouponPage> getAllCouponPageByPage(Integer page, Integer size) {
        return operatorCouponPageRepository.findAll(new PageRequest(page, size));
    }

    @Override
    public void deleteCouponPageById(String id) {
        operatorCouponPageRepository.delete(id);
    }

    @Override
    public OperatorCouponPage getCouponPageById(String id) {
        return operatorCouponPageRepository.findOne(id);
    }
}
